<?php
/*
 * Created on Aug 30, 2012
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
include_once("../configure/configure.php");		//--> global var
include_once("../admin/configure/admin.config.inc.php");		//--> global var

include_once("../admin/lib/apis/GoogleAffiliateApi.php");
include_once("../lib/impl/AdvertiserImpl.php");

include_once("../lib/impl/MerchantImpl.php");


$merImpl 	= new MerchantImpl(DB_TAG_COUPON);

$adImpl		= new AdvertiserImpl(DB_TAG_COUPON);

$ga 		= new GoogleAffiliateApi();

$ga->init();


$arrAdvertisers = $ga->getAdvertisers("approved");

echo "count: " . count($arrAdvertisers);
echo "\n";

$insertMerchantCount	= 0;
$updateMerchantCount	= 0;

foreach($arrAdvertisers as $adv){	
//	$oMer = $merImpl->getMerchantByAdvertiserId($adv->getId());
//	
//	// find merchant by alias
//	if(!is_object($oMer)){
//		$oMer = $merImpl->getByAlias($adv->getName());		
//	}
//	
//	if(is_object($oMer)){
//		$adImpl->updateMerchantByGooglAdvertiser($oMer, $adv);
//		
//		$updateMerchantCount++;
//		
//	}else{		
//		$adImpl->addMerchantByGooglAdvertiser($adv);
//		
//		$insertMerchantCount++;
//		
//	}

	
}

echo "insert merchant count: " . $insertMerchantCount;
echo "\n";

echo "update merchant count: " . $updateMerchantCount;
echo "\n";

?>
